home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 659 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.6 KB

  1. Path: ix.netcom.com!netnews
  2. From: cfoster1@ix.netcom.com(Cameron Foster )
  3. Newsgroups: alt.msdos.programmer,comp.lang.c
  4. Subject: Re: Two C problems
  5. Date: 7 Jan 1996 19:48:36 GMT
  6. Organization: Netcom
  7. Message-ID: <4cp82k$gsq@cloner3.netcom.com>
  8. References: <4cojnn$rgd@lugb.latrobe.edu.au>
  9. NNTP-Posting-Host: ple-ca6-01.ix.netcom.com
  10. X-NETCOM-Date: Sun Jan 07 11:48:40 AM PST 1996
  11.  
  12. In <4cojnn$rgd@lugb.latrobe.edu.au> csigjb@luxor.latrobe.edu.au ()
  13. writes: 
  14. >
  15. >I have two C problems.
  16. >
  17. >PROBLEM 1 :
  18. >
  19.  
  20. Didn't have time to look at problem 1 yet, but as to problem 2:
  21.  
  22. >PROBLEM 2 :
  23. >
  24. >const escape=27;
  25. >const cr=13;
  26. >const bs=8;
  27. >
  28. >while (ch!=cr)
  29. >{
  30. >     .
  31. >     .
  32. >     .
  33. >}
  34. >
  35. >while (ch!=escape)
  36. >{
  37. >     .
  38. >     .
  39. >     .
  40. >}
  41. >
  42. >If I replace the 27 with \27' or the 13 with '\13' then these loops
  43. don't
  44. >work i.e. an infinite loop results. WHY?
  45. >
  46. >Also if I want to do somthing like this : puts("\24 \25"); which
  47. should
  48. >print the up and down arrows on the screen (ASCII 24 and 25), but no,
  49. it
  50. >prints some other ASCII characters. As far as I can tell C has its own
  51. >unique character table, at least for the control characters. WHY?
  52. >
  53. >Sometimes I wonder whether some one needs to go back an rewrite the
  54. damn
  55. >language so that it works sensibly and predictably like Pascal can be
  56. >relied upon to do.
  57.  
  58. Actually, the "damn language" IS working sensibly and predictably! Read
  59. up on C escape sequences. 
  60.  
  61. int i = 27;     /* i has the decimal value of 27 */
  62. int i = \27;    /* i has the decimal value of 23 (\27 is the octal */  
  63.                 /* representation of decimal 23) */
  64. int i = \x27    /* i has the decimal value of 39 */
  65.  
  66.  
  67.